wayland: stage uncommitted changes to dedicated buffer
authorRay Strode <rstrode@redhat.com>
Fri, 29 Jan 2016 16:19:03 +0000 (11:19 -0500)
committerRay Strode <rstrode@redhat.com>
Sat, 6 Feb 2016 13:02:57 +0000 (08:02 -0500)
commitc80dd549242abff7dfbf8f636da8a5e2c7d97b8f
tree7e18b537643aa78d0b6dcbc35e842968b8955e3e
parent40e91195ad8a20c073789dad192e7aaaf9af6eca
wayland: stage uncommitted changes to dedicated buffer

Right now we use one buffer for both staged changes (freshly painted
changes waiting for the frame clock to send to the compositor) and
committed changes (changes actively being read by the compositor
process). This creates a problem in the event we need to stage updates
at the same time the compositor is processing committed updates: we
can't change what the compositor is actively processing.

The current solution for handling this contention is to allocate a
temporary buffer on the spot at the time the updates are staged, and to
copy that buffer back to the shared buffer later.  The problem, though,
is that the copy to the shared buffer currently happens as soon as
the updates are finished being staged, not when the shared buffer is
done being processed by the compositor.

In order to address that problem, this commit changes the code to always
stage changes to a dedicated staging buffer.  The staging buffer is
used exclusively by the client until the client is done with it, and then
once that staging buffer is committed, the client never writes to that
buffer again.  If the client needs to stage new updates, it allocates a
brand new staging buffer, draws to it, and back fills the undrawn parts
of the buffer from a copy of the contents of the committed buffer.

As an optimization, the compositor has the option of releasing the
committed buffer back to the client.  If it does so before the client
needs to stage new updates, then the client will reuse the buffer
for staging future updates.  This optimization prevents having to allocate
a new staging buffer and the associated cost of back filling
that new buffer with a readback of the committed buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=761312
gdk/wayland/gdkwindow-wayland.c